package com.itheima.dao;

import com.itheima.pojo.Tag;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

@Repository
public interface TagDao extends Mapper<Tag> {

    @Select("SELECT tag_uid, COUNT(tag_uid) as referCount FROM  t_blog where status=1  GROUP BY tag_uid")
    List<Map<String, Object>> selectSortByCite();

    @Select("SELECT uid,content,status,click_count,create_time,update_time,sort FROM t_tag  WHERE  status = 1 order by click_count DESC")
    List<Tag> selectSortByClickCount();

    /**
     * 获取每个标签下文章数目
     */
    @Select("SELECT t.content  name,  COUNT(t.uid) value ,b.tag_uid tagUid FROM  t_blog b,t_tag t WHERE t.uid = b.tag_uid GROUP BY t.uid;")
    List<Map<String, Object>> getBlogCountByTag();

}
